package com.shine.chemicalWholeProcessSystem.view.pop;

import android.content.Context;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.interfaces.OnCancelListener;
import com.lxj.xpopup.interfaces.OnConfirmListener;
import com.lxj.xpopup.util.XPopupUtils;
import com.shine.chemicalWholeProcessSystem.R;

public class RiskManagementSearchPopup extends BottomPopupView {
    OnConfirmListener confirmListener;
    OnCancelListener cancelListener;
    EditText name, number;


    public RiskManagementSearchPopup(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.popup_risk_management_search;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        name = findViewById(R.id.name);
        number = findViewById(R.id.number);

        findViewById(R.id.reset).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                cancelListener.onCancel();
                name.setText("");
                number.setText("");
            }
        });
        findViewById(R.id.search).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmListener.onConfirm();
                dismiss();
            }
        });
    }

    public RiskManagementSearchPopup setListener(OnConfirmListener confirmListener, OnCancelListener onCancelListener) {
        this.confirmListener = confirmListener;
        this.cancelListener = onCancelListener;
        return this;
    }

    public String getRiskName(){
        return name.getText().toString();
    }

    public String getRiskNum(){
        return number.getText().toString();
    }

    //完全可见执行
    @Override
    protected void onShow() {
        super.onShow();
    }

    //完全消失执行
    @Override
    protected void onDismiss() {
    }

    @Override
    protected int getMaxHeight() {
//        return XPopupUtils.getWindowHeight(getContext());
        return (int) (XPopupUtils.getWindowHeight(getContext()) * .9f);
    }

}
